﻿using DataService.Core.Threading;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UnitTest
{
    /// <summary>
    /// 测试定时器
    /// </summary>
    public static class TestTimerHelper
    {

        public static void Timer_1()
        {
            // 1秒之后 每3秒执行一次
            TimerHelper timer1 = new TimerHelper(Do_1, null, 1_000, 3_000) { Async = true };

            // 指定开始时间，每3秒执行一次
            DateTime time = DateTime.Parse("2023-5-14 17:27:44");
            TimerHelper timer2 = new TimerHelper(Do_2, null, time, 3_000) { Async = true };

            //每天 【凌晨2点0分0秒】执行一次
            TimerHelper timer3 = new TimerHelper(Do_3, null, "0 0 2 * * *") { Async = true };

            //【每月14号17点48分0秒】执行一次
            TimerHelper timer4 = new TimerHelper(Do_4, null, "0 48 17 14 * *") { Async = true };

            //【每个工作日的凌晨2点0分0秒】执行一次
            TimerHelper timer5 = new TimerHelper(Do_5, null, "0 0 2 * * 1-5") { Async = true };
           
        }
        public static void Do_1(object state)
        {
            Console.WriteLine($"do_1>{DateTime.Now}");
        }
        public static void Do_2(object state)
        {
            Console.WriteLine($"do_2>{DateTime.Now}");
        }
        public static void Do_3(object state)
        {
            Console.WriteLine($"do_3>{DateTime.Now}");
        }
        public static void Do_4(object state)
        {
            Console.WriteLine($"do_4>{DateTime.Now}");
        }

        public static void Do_5(object state)
        {
            Console.WriteLine($"do_5>{DateTime.Now}");
        }
    }
}
